<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Practice_Models extends CI_Model {
	function __construct(){
        // Call the Model constructor
        parent::__construct();
    }

	function getKaryawan($id,$page){
		
		$this->db->select('karyawan_id, karyawan_nama, karyawan_umur, karyawan_status'); 
		$this->db->from('karyawan');
		$this->db->limit(5, $page);
		
		if(isset($id))
		$this->db->where('karyawan_id',$id);
		// $this->db->where('password',md5($password)); 
		// $this->db->limit(1); 

		$query = $this->db->get();
		if($query->num_rows()>0){
			return $query->result();
		}else{
			return array();
       //  $query = $this->db->get('entries', 10);
       //return $query->result(); --> 
		}
    }

    function countKaryawan(){
    	$total = $this->db->count_all('karyawan');

    	return $total;
    }

    function insertKaryawan($data){
		$this->db->insert('karyawan', $data);
	}

	function updateKaryawan($data){
		$this->db->where('karyawan_id', $data['karyawan_id']);
		$this->db->update('karyawan', $data);
	}

	function deleteKaryawan($id){
		$this->db->where('karyawan_id', $id);
		$this->db->delete('karyawan'); 
	}
}
?>